/**
 * @description 本地存储相关的方法
 * @author xfj
 */

function setStorage(key, value) {
  if(typeof value === "object") {
    try {
      value = JSON.stringify(value)
    }catch(err){
      value = ''
    }
  }
  window.localStorage.setItem(key, value)
}

function getStorage(key) {
  let value = window.localStorage.getItem(key)
  try {
    value = JSON.parse(value)
  }catch(err){}
  return value;
}

export {
  setStorage,
  getStorage,
}
